//
//  ETitleButtonCell.m
//  Common
//
//  Created by shiqing guo on 2018/7/31.
//  Copyright © 2018年 www.bitkinetic.com. All rights reserved.
//

#import "ETitleButtonCell.h"
#import "Macro.h"
#import "UIView+DDAddition.h"

@interface ETitleButtonCell ()
@property (strong, nonatomic) UIButton *btnSelect;
@end

@implementation ETitleButtonCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.frame = frame;
        [self addSubview:self.btnSelect];
    }
    return self;
}

- (UIButton *)btnSelect
{
    if (!_btnSelect) {
        _btnSelect = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
        [_btnSelect setTitleColor:[EPColor epColor_descMessageGray] forState:UIControlStateNormal];
        _btnSelect.layer.masksToBounds = YES;
        _btnSelect.layer.cornerRadius = 4.f;
        _btnSelect.layer.borderWidth = 0.5f;
        _btnSelect.layer.borderColor = [EPColor epColor_descMessageGray].CGColor;
        _btnSelect.userInteractionEnabled = NO;
        _btnSelect.titleLabel.font = SystemFont(12.f);
    }
    return _btnSelect;
}

- (void)setStrTypeName:(NSString *)strTypeName
{
    [self.btnSelect setTitle:strTypeName forState:UIControlStateNormal];
    [self setNeedsDisplay];
}

- (void)setIsSelected:(BOOL)isSelected
{
    UIColor *colorText = isSelected?[UIColor whiteColor]:[EPColor epColor_descMessageGray];
    UIColor *colorBkw = isSelected?[EPColor epColor_Blue]:[UIColor whiteColor];
    [self.btnSelect setTitleColor:colorText forState:UIControlStateNormal];
    self.btnSelect.backgroundColor = colorBkw;
    [self setNeedsDisplay];
}

@end
